home *** CD-ROM | disk | FTP | other *** search
- class disney.rabbitRivalry.ents.Player extends disney.rabbitRivalry.ents.Entity
- {
- var __currentWeapon;
- var assetID;
- var isCharging;
- var isAttacking;
- var isFlying;
- var mc;
- var gravityVector;
- var __moveDt;
- var __xAngleCalc;
- var __yAngleCalc;
- var __angle;
- var __isPoweringUp;
- var __power;
- var __powerMeter_frames;
- var nextY;
- var startY;
- var y;
- var velocity;
- var __animation;
- var __isAnimating;
- var isPerfect;
- var didHit;
- var __bounceCount;
- var isAlive;
- var x;
- var hdReg;
- var baseHeight;
- var TYPE = "player";
- var DRAWTYPE = "player";
- var __DEF_ASSET = "yang_mc";
- var __DEF_WIDTH = 120;
- var __DEF_HEIGHT = 190;
- var __USE_ACTUAL_DIMENSIONS = true;
- var __DEF_HD_WIDTH = 80;
- var __DEF_HD_HEIGHT = 160;
- var __USE_DIMENSIONS_AS_HD = false;
- var CUSTOMDRAW = true;
- var __POWER_RATE = 100;
- var __MAX_POWER = 100;
- var __MIN_POWER = 30;
- var __MINMAX_POWER_DIFF = disney.rabbitRivalry.ents.Player.prototype.__MAX_POWER - disney.rabbitRivalry.ents.Player.prototype.__MIN_POWER;
- var __MIN_ANGLE = 270;
- var __MAX_ANGLE = 350;
- var __MAX_VELOCITY = 2800;
- var __POWER_MULTIPLIER = 8.9;
- function Player(t_data)
- {
- super(t_data);
- this.__currentWeapon = 1;
- if(disney.rabbitRivalry.GameState.getInstance().isYang)
- {
- this.assetID = "yang_mc";
- }
- else
- {
- this.assetID = "yin_mc";
- }
- this.isCharging = this.isAttacking = this.isFlying = false;
- }
- function equip(num)
- {
- this.__currentWeapon = num;
- this.mc.anim.weapon.gotoAndStop(this.__currentWeapon);
- }
- function reset()
- {
- super.reset();
- this.gravityVector = disney.rabbitRivalry.GameState.getInstance().GRAVITY;
- }
- function moveAndRender(camera, dt)
- {
- dt *= 2;
- super.moveAndRender(camera,dt);
- }
- function update(dt)
- {
- this.__moveDt = dt * 1.5;
- super.update(this.__moveDt);
- if(this.isCharging)
- {
- this.__xAngleCalc = this.mc.center_mc._xmouse;
- this.__yAngleCalc = this.mc.center_mc._ymouse;
- if(this.__xAngleCalc >= 0)
- {
- if(this.__yAngleCalc >= 0)
- {
- this.__angle = 0;
- }
- else
- {
- this.__angle = 360;
- }
- }
- else
- {
- this.__angle = 180;
- }
- this.__angle += Math.atan(this.__yAngleCalc / this.__xAngleCalc) * 57.29577951308232;
- if(this.__angle > this.__MAX_ANGLE || this.__angle < 180)
- {
- this.__angle = this.__MAX_ANGLE;
- }
- else if(this.__angle < this.__MIN_ANGLE)
- {
- this.__angle = this.__MIN_ANGLE;
- }
- this.mc.angleBar_mc._rotation = this.__angle;
- if(this.__isPoweringUp)
- {
- this.__power += this.__POWER_RATE * dt;
- if(this.__power >= this.__MAX_POWER)
- {
- this.__power = this.__MAX_POWER;
- this.__isPoweringUp = false;
- }
- }
- else
- {
- this.__power -= this.__POWER_RATE * dt;
- if(this.__power <= this.__MIN_POWER)
- {
- this.__power = this.__MIN_POWER;
- this.__isPoweringUp = true;
- }
- }
- this.mc.angleBar_mc.powerMeter_mc.gotoAndStop(Math.round((this.__power - this.__MIN_POWER) / this.__MINMAX_POWER_DIFF * this.__powerMeter_frames));
- }
- else if(this.isFlying)
- {
- this.addVelocity(this.gravityVector,this.__moveDt);
- if(this.nextY > this.startY)
- {
- this.hitGround(this.startY);
- }
- }
- }
- function hitGround(t_y)
- {
- this.y = this.nextY = t_y;
- this.isFlying = false;
- this.animate("land");
- this.velocity = new smashing.Point3D(0,0,0);
- }
- function grimace()
- {
- if(this.__animation != "hit")
- {
- disney.rabbitRivalry.Sounds.getInstance().p("yoHit" + Math.ceil(Math.random() * 2));
- }
- this.animate("hit");
- }
- function onMouseDown()
- {
- if(this.isCharging)
- {
- this.disablePowerAndAim();
- this.animate("launch");
- this.isAttacking = false;
- return true;
- }
- return false;
- }
- function animate(frame)
- {
- super.animate(frame);
- this.mc.anim.weapon.gotoAndStop(this.__currentWeapon);
- }
- function updateAnim()
- {
- if(this.__isAnimating)
- {
- if(this.mc.anim._currentFrame == this.mc.anim._totalFrames)
- {
- if(this.__animation == "launch")
- {
- this.animate("fly");
- if(this.__angle < this.__MAX_ANGLE)
- {
- this.__power -= 25 * (1 - (this.__angle - (this.__MIN_ANGLE - 1)) / (this.__MAX_ANGLE - this.__MIN_ANGLE));
- }
- this.__power = 30 + 70 * (this.__power / 100);
- this.velocity = this.magnitudeToVector(this.__power * this.__POWER_MULTIPLIER,this.__angle);
- this.isPerfect = true;
- this.isFlying = true;
- }
- else if(this.__animation == "land")
- {
- if(this.y >= this.startY)
- {
- this.animate("lose");
- smashing.keithm.Messenger.sendMessage("screen","runResultAnim",{type:"miss"});
- this.isAttacking = false;
- }
- else
- {
- this.animate("attack_" + this.__currentWeapon);
- this.isAttacking = true;
- if(this.assetID == "yang_mc")
- {
- disney.rabbitRivalry.Sounds.getInstance().p("yangattack");
- }
- else
- {
- disney.rabbitRivalry.Sounds.getInstance().p("yinattack");
- }
- }
- }
- else if(this.__animation.indexOf("attack_") > -1)
- {
- if(this.didHit)
- {
- this.animate("win");
- }
- else
- {
- this.animate("lose");
- }
- this.isAttacking = false;
- }
- else if(this.__animation == "win")
- {
- smashing.keithm.Messenger.sendMessage("world","goNextRabbit");
- this.__animation = "freeze";
- }
- else if(this.__animation == "lose")
- {
- smashing.keithm.Messenger.sendMessage("world","onMiss");
- this.__animation = "freeze";
- }
- }
- }
- }
- function enablePowerAndAim()
- {
- this.animate(this.__IDLE_ANIMATION);
- this.isCharging = true;
- this.mc.angleBar_mc._visible = true;
- this.didHit = false;
- this.__power = this.__MIN_POWER;
- this.__isPoweringUp = true;
- this.__angle = 0;
- this.__bounceCount = 0;
- }
- function disablePowerAndAim()
- {
- this.isCharging = false;
- this.mc.angleBar_mc._visible = false;
- this.mc.angleBar_mc.powerMeter_mc.gotoAndStop(1);
- this.mc.angleBar_mc._rotation = 0;
- }
- function onDraw(newmc)
- {
- super.onDraw(newmc);
- if(!this.isCharging)
- {
- this.disablePowerAndAim();
- }
- this.__powerMeter_frames = this.mc.angleBar_mc.powerMeter_mc._totalFrames;
- }
- function bounce(bounceRight)
- {
- if(this.__bounceCount > 2)
- {
- return undefined;
- }
- this.__bounceCount = this.__bounceCount + 1;
- this.isPerfect = false;
- if(bounceRight == true)
- {
- this.velocity.x = 90;
- }
- else
- {
- this.velocity.x = -60;
- }
- this.velocity.y = -100;
- }
- function runHD(t_target, dt)
- {
- if(!(this.isAlive && t_target.isAlive))
- {
- return false;
- }
- if(!this.isAttacking)
- {
- return super.runHD(t_target,dt);
- }
- if(t_target.x < this.x || !t_target.isDrawn)
- {
- return false;
- }
- if(this.mc.hitTest(t_target.mc))
- {
- return true;
- }
- return false;
- }
- function setHDRegistration()
- {
- this.hdReg = {};
- this.hdReg.x = 0;
- this.hdReg.y = - this.baseHeight / 2;
- }
- function isAttackFrame()
- {
- if(this.assetID == "yang_mc")
- {
- var _loc2_ = undefined;
- if(this.__currentWeapon == 2)
- {
- _loc2_ = 6;
- }
- else
- {
- _loc2_ = 15;
- }
- }
- else if(this.__currentWeapon == 3)
- {
- _loc2_ = 53;
- }
- else if(this.__currentWeapon == 2)
- {
- _loc2_ = 35;
- }
- else
- {
- _loc2_ = 19;
- }
- if(this.isAttacking && this.mc.anim._currentFrame > _loc2_)
- {
- return true;
- }
- return false;
- }
- }
-